home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
8bitfiles.net/archives
/
archives.tar
/
archives
/
commodore-users-of-norman
/
CUON_38_(10-1984).d64
/
alphabetize dir
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2019-04-13
|
3KB
|
77 lines
1 PRINT"":POKE53280,0:POKE53281,0
10 REM*********************************
20 REM* *
30 REM* S O R T D I R *
40 REM* *
50 REM* VER 1.0 (C) 1983 BY CHRISDOS *
60 REM* DONATED TO THE PUBLIC DOMAIN *
70 REM* *
80 REM*********************************
85 REM THIS UTILITY FOR THE C64 WILL
86 REM SORT THE DISK DIRECTORY AND
87 REM WRITE IT BACK TO THE DISK.
88 REM IN ADDITION, IT WILL GROUP
89 REM FILES TOGETHER BY TYPE.
90 REM SIMPLY RUN THIS PROGRAM. NO
91 REM OTHER INPUT IS NEEDED.
92 REM -CHRISDOS [70001,766]
95 PRINT"[147] S O R T D I R BY CHRISDOS":PRINT:PRINT" MODIFIED BY TONY DAVIS"
96 PRINT:PRINT:PRINT
100 DIM DR$(145),S(20),NM$(145)
110 OPEN15,8,15:REM COMMAND CHAN.
120 OPEN5,8,5,"#":REM FILE CHAN.
130 S(1)=1:DE=0:REM SECTOR 1. DIRECTORY ENTRY 0
140 I=1:REM FIRST READ
200 PRINT#15,"U1:";5;0;18;S(I):REM READ THE SECTOR
205 PRINT"READING SECTOR: "S(I)
210 I=I+1:REM PREPARE FOR NEXT SECTOR
220 GET#5,T$:REM GET THE TRACK BYTE - IGNORE IT
230 GET#5,S$:S(I)=ASC(S$+CHR$(0)):REM GET THE NEXT SECTOR POINTER
240 FORQ=1TO8:I$="":REM LOOP TO GET THE 8 DIR ENTRIES
245 DE=DE+1:DR$(DE)="":REM INCR. # OF ENTRIES
250 FORR=1TO30:REM LOOP TO BUILD THE ENTRY
260 GET#5,I$:REM GET THE BYTE
265 IFI$=""THENI$=CHR$(0):REM PAD IT IF NULL
270 DR$(DE)=DR$(DE)+I$:REM BUILD THE STRING
280 NEXT R
285 IFQ<>8THENGET#5,NG$,NG$:REM BYPASS 2 UNUSED BYTES
287 NEXT Q
290 IFS(I)<21THEN 200:REM CHECK NEXT SECTOR POINTER. LOOP IF MORE TO READ
300 GOSUB 800:REM PRINT THE DIRECTORY
305 PRINT"CONVERTING FILE NAMES......"
310 FOR X=1TODE:REM LOOP TO CONVERT FILE NAMES
320 NM$(X)=LEFT$(DR$(X),1)+MID$(DR$(X),4,16):REM PUT FILE TYPE BYTE IN FRONT
330 FORP=2TO17:REM LOOP TO HACK SHIFTED SPACES FROM END
340 IFMID$(NM$(X),P,1)=CHR$(160)THENNM$(X)=MID$(NM$(X),1,P-1):GOTO360
350 NEXT P
360 NEXT X
400 PRINT"SORTING.......";
405 FOR X=1TO DE-1:REM SIMPLE BUBBLE SORT
410 IFNM$(X)>NM$(X+1)THEN450:REM CHECK NAME WITH NEXT ONE. SWAP IF BIGGER
420 Z$=STR$(DE-X-1):Z$=Z$+" ":Z$=LEFT$(Z$,3):PRINT"[157][157][157]"Z$;
430 NEXT X
440 PRINT:GOTO 500:REM FINISHED !
450 HO$=DR$(X):DR$(X)=DR$(X+1):DR$(X+1)=HO$:REM SWAP ENTRIES
455 HO$=NM$(X):NM$(X)=NM$(X+1):NM$(X+1)=HO$:REM SWAP NAMES
460 X=X-1:IFX<1THENX=1:REM BACK UP
470 GOTO 410:REM AND CHECK AGAIN
500 GOSUB 800:REM PRINT THE SORTED NAMES
510 W=I-1:DW=0:REM W=NUMBER OF BLOCKS TO WRITE
520 FOR I=1TOW:PRINT#15,"B-P:";5;0:REM LOOP TO WRITE. FORCE BUF POINT TO BEGIN
522 TT=18:IFS(I+1)=255THENTT=0:REM TRACK # TO WRITE. 0 IF LAST BLOCK
525 PRINT#5,CHR$(TT);CHR$(S(I+1));:REM PUT THE TRACK AND NEXT SECTOR
530 FOR Q=1TO8:DW=DW+1:REM LOOP TO PUT THE DIR ENTRIES
540 PRINT#5,DR$(DW);:REM PUT THE ENTRY
550 IFQ<>8THENPRINT#5,"CD";:REM PUT IN 2 DUMMY BYTES
560 NEXT Q
570 PRINT#15,"U2:";5;0;18;S(I):REM WRITE THE SECTOR
573 PRINT"WRITING SECTOR: "S(I)
580 NEXT I
590 PRINT"D O N E "
600 CLOSE5:CLOSE15:STOP
800 PRINT"[147]":FOR Q=1TODE:REM LOOP THROUGH THE ENTRIES
810 IFMID$(DR$(Q),1,1)=CHR$(0)THEN830:REM SKIP 'DELEATED' ONES
820 PRINTMID$(DR$(Q),4,16):REM PRINT NAMES
830 NEXT Q
840 RETURN